var session = sessionStorage.getItem("session");
if (!session) {
	window.parent.location = "../../login.html";
}

$(function() {
	$("#jqGrid").jqGrid({
		url: IP + "GetProbrPerformance?callback=?&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			width: 50,
			hidden: true,
		}, {
			label: "设备唯一编码",
			name: 'deviceid',
			width: 200
		}, {
			label: "设备名称",
			name: 'deviceName',
			width: 200
		}, {
			label: '客户名称',
			name: 'customerName',
			width: 300,
		}, {
			label: '客户经理',
			name: 'customerManager',
			width: 200,
		}, {
			label: '安装地址',
			name: 'install',
			width: 300,
		}, {
			label: "CPU(%)",
			name: 'cpu',
			width: 120,
		}, {
			label: '内存(G)',
			name: 'mem',
			width: 120,
		}],
		loadonce: true,
		viewrecords: true,
		autowidth: true,
		rownumbers: true,
		rowNum: 20,
		page: 1,
		loadtext: '正在加载数据',
		pager: "#jqGridPager"
	});
   var  h=$("body").height();
   $("#jqGrid").jqGrid("setGridHeight",h-120)
	var template1 = {
		"groupOp": "AND",
		"rules": [{
			"field": "deviceid",
			"op": "eq",
			"data": "硬探针",
		}, {
			"field": "CPU",
			"op": "eq",
			"data": "AMD"
		}]
	};
	// activate the build in search with multiple option
	$('#jqGrid').navGrid("#jqGridPager", {
			search: true, // show search button on the toolbar
			add: false,
			edit: false,
			del: false,
			refresh: true
		}, {}, // edit options
		{}, // add options
		{}, // delete options
		{
			multipleSearch: true,
			multipleGroup: true,
			showQuery: true,
			// set the names of the template
			tmplNames: ["模板一"],
			// set the template contents
			tmplFilters: [template1]
		} // search options - define multiple search
	);
	insertopertlog('探针管理', '探针性能监测', '查询', '', '');
	var timer;
	$("#search").on("keyup", function() {
		var self = this;
		console.log(this.value)
		if (timer) {
			clearTimeout(timer);
		}
		timer = setTimeout(function() {
			//timer = null;
			$("#jqGrid").jqGrid('filterInput', self.value);
		}, 0);
	});
});